using System;
using System.Windows.Forms;
using ctsu.Shared;

namespace ctsu.BaseForms
{
	public enum DbTableChange
	{
		Insert,
		Update,
		Delete
	}

	public enum ValidationType
	{
		Field,
		Summary
	}

	public class MessageQEventArgs
	{
		public string MessageType;
		public BLFormReqestBaseEventArgs EventArgs;
		public MessageQEventArgs(string type, BLFormReqestBaseEventArgs args)
		{
			this.MessageType = type;
			this.EventArgs = args;
		}
	}

	public class BLReturnIDEventArgs
	{
		public string FormClassName;
		public int ID;

		public BLReturnIDEventArgs(string formClassName, int id)
		{
			this.FormClassName = formClassName;
			this.ID = id;
		}
	}

	public class BLFormReqestBaseEventArgs
	{
		public string RequestingFormClassName;
		public string TargetFormClassName;

		public BLFormReqestBaseEventArgs(string requestingFormClassName, string targetFormClassName)
		{
			this.RequestingFormClassName = requestingFormClassName;
			this.TargetFormClassName = targetFormClassName;
		}
	}

	public class BLFormRequestEventArgs : BLFormReqestBaseEventArgs
	{
		public bool SendReturn;

		public BLFormRequestEventArgs(string requestingFormClassName, string targetFormClassName, bool sendReturn)
			: base(requestingFormClassName, targetFormClassName)
		{
			this.RequestingFormClassName = requestingFormClassName;
			this.TargetFormClassName = targetFormClassName;
			this.SendReturn = sendReturn;
		}
	}

	public class BLModeChangeEventArgs
	{
		public EditMode OldMode;
		public EditMode NewMode;

		public BLModeChangeEventArgs(EditMode oldMode, EditMode newMode)
		{
			this.OldMode = oldMode;
			this.NewMode = newMode;
		}
	}

	public class BLTableChangeEventArgs
	{
		public string TableName;
		public DbTableChange TableChange;

		public BLTableChangeEventArgs(string tableName, DbTableChange tableChange)
		{
			this.TableName = tableName;
			this.TableChange = tableChange;
		}
	}

	public class BLTableChangeAdvEventArgs : BLTableChangeEventArgs
	{
		public int CurrentRow;
		public BLTableChangeAdvEventArgs(string tableName, DbTableChange tableChange, int currentRow)
			: base(tableName, tableChange)
		{
			this.CurrentRow = currentRow;
		}
	}

	public class BLGridViewEventArgs
	{
		public string Title;
		public Form GridForm;

		public BLGridViewEventArgs(string title, Form gridForm)
		{
			this.Title = title;
			this.GridForm = gridForm;
		}
	}

	public class BLGridValidateErrorEventArgs
	{
		public Control Control;
		public string Message;

		public BLGridValidateErrorEventArgs(Control control, string message)
		{
			this.Control = control;
			this.Message = message;
		}
	}

	public class BusinessLogicEvents
	{
		public delegate void BusinessEventNotifyHandler();
		public delegate void BLTableChangeEventHandler(object sender, BLTableChangeEventArgs e);
		public delegate void BLGridViewEventHandler(object sender, BLGridViewEventArgs e);
		public delegate void BLModeChangeEventHandler(object sender, BLModeChangeEventArgs e);
		public delegate void BLGridColumnValueChangedHandler(object sender, EventArgs e);
		public delegate void BLGridValidateErrorEventHandler(object sender, BLGridValidateErrorEventArgs e);
		public delegate void BLRequestIDFromOtherFormHandler(object sender, MessageQEventArgs e);
		public delegate void BLReturnIDToRequestingFormHandler(object sender, BLReturnIDEventArgs e);
		public delegate void BLSelectedItemEventHandler(object sender, BLReturnIDEventArgs e);

	}
}
